Merge "Avoid CAS errors on double post to ApiOptions"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 28 Sep 2015 20:17:22 +0000 (20:17 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 28 Sep 2015 20:17:22 +0000 (20:17 +0000)
includes/User.php
includes/api/ApiOptions.php

index faf1bdc..f089f08 100644 (file)
@@ -1203,18 +1203,15 @@ class User implements IDBAccessObject {
                        return false;
                }
 
-               $db = ( $flags & self::READ_LATEST )
-                       ? wfGetDB( DB_MASTER )
-                       : wfGetDB( DB_SLAVE );
+               list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags );
+               $db = wfGetDB( $index );
 
                $s = $db->selectRow(
                        'user',
                        self::selectFields(),
                        array( 'user_id' => $this->mId ),
                        __METHOD__,
-                       ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING )
-                               ? array( 'LOCK IN SHARE MODE' )
-                               : array()
+                       $options
                );
 
                $this->queryFlagsUsed = $flags;
index a62bcb6..74ce053 100644 (file)
@@ -55,7 +55,7 @@ class ApiOptions extends ApiBase {
                // Load the user from the master to reduce CAS errors on double post (T95839)
                if ( wfGetLB()->getServerCount() > 1 ) {
                        $user = User::newFromId( $user->getId() );
-                       if ( !$user->loadFromId( User::READ_LATEST ) ) {
+                       if ( !$user->loadFromId( User::READ_EXCLUSIVE ) ) {
                                $this->dieUsage( 'Anonymous users cannot change preferences', 'notloggedin' );
                        }
                }